var form = layui.form;
form.on('submit(LAY-user-back-search)', function (data) {
    $('.fault-content').css("display","block");
    var etCode = data.field.etCode;
    var faultContent =data.field.faultContent;
    $.ajax({
        type : "get",
        async : false, //异步执行
        url : '/ec/getEquipmentMsg?etCode='+etCode+'&&faultContent='+faultContent+'',
        dataType : "json", //返回数据形式为json
        success : function(data) {
            var dataInformations = data.data.etInformations;
            if (dataInformations.length  === 0 ){
                $('.domain').html("");
                $('.systemName').html("");
                $('.etType').html("");
                $('.etCode').html("");
                $('.etName').html("");
                $('.lineId').html("");
                $('.stationName').html("");
                $('#owner').html("");
                $('#etModel').html("");
                $('#etSupplier').html("");
                $('#etProducer').html("");
                $('#dateOfProduction').html("");
                $('#guaranteePeriod').html("");
                $('#guaranteePeriod').html("");
                $('#serialNum').html("");
                $('#voltage').html("");
                $('#power').html("");
                $('#life').html("");
            }else {
                $('.domain').html(dataInformations[0].domain);
                $('.systemName').html(dataInformations[0].systemName);
                $('.etType').html(dataInformations[0].etType);
                $('.etCode').html(dataInformations[0].etCode);
                $('.etName').html(dataInformations[0].etName);
                $('.lineId').html(dataInformations[0].lineId);
                $('.stationName').html(dataInformations[0].stationName);
                $('#owner').html( dataInformations[0].owner);
                $('#etModel').html( dataInformations[0].etModel);
                $('#etSupplier').html( dataInformations[0].etSupplier);
                $('#etProducer').html(dataInformations[0].etProducer);
                $('#dateOfProduction').html( dataInformations[0].dateOfProduction);
                $('#guaranteePeriod').html( dataInformations[0].guaranteePeriod);
                $('#guaranteePeriod').html( dataInformations[0].guaranteePeriod);
                $('#serialNum').html( dataInformations[0].serialNum);
                $('#voltage').html( dataInformations[0].voltage);
                $('#power').html( dataInformations[0].power);
                $('#life').html( dataInformations[0].life);
            }
            if (data.data.etPatrolPlans.length === 0){
                $('#patrolLastTime').html("");
                $('#patrolNextTime').html("");
            }else {

                $('#patrolLastTime').html( data.data.etPatrolPlans[0].patrolLastTime);
                $('#patrolNextTime').html( data.data.etPatrolPlans[0].patrolNextTime);
            }
            layui.use('table', function(){
                var table = layui.table;
                table.render({
                    elem: "#faultHistory",
                    data: data.data.etMaintainRecords,
                    cols: [
                        [
                            //表头
                            {
                                field: "faultContent",
                                title: "故障描述",
                                align: "center",
                            },
                            {
                                field: "maintainPerson",
                                title: "维修人",
                                align: "center",
                            },
                            {
                                field: "maintainDate",
                                title: "维修时间",
                                align: "center",
                            },
                            {
                                field: "maintainWay",
                                title: "维修方式",
                                align: "center",
                            },



                        ],
                    ],
                    text: {
                        none: "暂无数据",
                    },
                    done: function (res, curr, count) {
                    },
                });
                table.render({
                    elem: "#deviceDispose",
                    data: data.data.deviceDispose,
                    cols: [
                        [
                            //表头
                            {
                                field: "faultContent",
                                title: "故障内容",
                                align: "center",
                            },
                            {
                                field: "dispose",
                                title: "处理方式",
                                align: "center",
                            }
                        ],
                    ],
                    text: {
                        none: "暂无数据",
                    },
                    done: function (res, curr, count) {
                    },
                });
            });
        },
        error : function(errorMsg) {
            alert("请求数据失败");
        }
    });
})
